package com.xxx.kjds.serviceImpl;

import com.xxx.kjds.entity.TraceExample;
import com.xxx.kjds.entity.TraceKey;
import com.xxx.kjds.mapper.TraceMapper;
import com.xxx.kjds.service.TraceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TraceServiceImpl implements TraceService {
    @Autowired
    private TraceMapper traceMapper;

    @Override
    public long countByExample(TraceExample example) {
        return traceMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(TraceExample example) {
        return traceMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(TraceKey key) {
        return traceMapper.deleteByPrimaryKey(key);
    }

    @Override
    public int insert(TraceKey record) {
        return traceMapper.insert(record);
    }

    @Override
    public int insertSelective(TraceKey record) {
        return traceMapper.insertSelective(record);
    }

    @Override
    public List<TraceKey> selectByExample(TraceExample example) {
        return traceMapper.selectByExample(example);
    }

    @Override
    public int updateByExampleSelective(TraceKey record, TraceExample example) {
        return traceMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(TraceKey record, TraceExample example) {
        return traceMapper.updateByExample(record, example);
    }

    //根据fid查钱包和流水表对应关系表
    @Override
    public TraceKey selectByFid(Integer fid) {
        TraceExample traceExample = new TraceExample();
        TraceExample.Criteria criteria = traceExample.createCriteria();
        criteria.andFcIdEqualTo(fid);
        List<TraceKey> list = traceMapper.selectByExample(traceExample);
        if(list.size()>0){
            return list.get(0);
        }
        return null;
    }

    @Override
    public List<TraceKey> selectByWid(Integer wid) {
        TraceExample traceExample = new TraceExample();
        TraceExample.Criteria criteria = traceExample.createCriteria();
        criteria.andWalletsIdEqualTo(wid);
        return traceMapper.selectByExample(traceExample);
    }
}
